package com.aaa.controller;

import com.aaa.entity.Dept;
import com.aaa.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/12/7
 */
@RestController
@RequestMapping("dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    //添加
    @PostMapping
    public Dept save(@RequestBody Dept dept){
        return deptService.save(dept);
    }
    //删除
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return deptService.delete(id);
    }
    //修改
    @PutMapping
    public Dept update(@RequestBody Dept dept){
        return deptService.update(dept);
    }
    //查询
    @GetMapping("/{id}")
    public Dept getById(@PathVariable Integer id){
        return deptService.findById(id);
    }
}
